// pages/index/evaluate/moreEvaluete.js
var app = getApp();
import Api from '../../../api/api.js';
const api = new Api();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    pageIndex: 1,
    pageCount: 10,
    contentId: "",
    contentType: "",
    connentList: [],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    this.data.contentId = options.id;
    this.data.contentType = options.contentType;
    this.getMoreData();
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {

  },
  getMoreData() {
    var _this = this;
  
    var map = {};
    map.contentId = this.data.contentId;;
    map.contentType = this.data.contentType;;
    map.userId = app.USER_ID();
    map.pageCount = this.data.pageCount;
    map.pageIndex = this.data.pageIndex;
    api.getRequestData(app.commonListUrl, map, true, "POST").then(res => {
      console.log(JSON.stringify(res));
      if (res.data.errorCode == 0) {
        var list = res.data.model;
        console.log(JSON.stringify(list[0]));
        if (list.length == 0) {
          app.alert("没有更多数据了～");
        }
        if (_this.data.pageIndex == 1) {
          _this.data.connentList = list;
          _this.setData({
            connentList: _this.data.connentList
          });
        } else {
          // 加载更多
          _this.setData({
            connentList: _this.data.connentList.concat(list)
          });
        }
      } else {
        wx.showToast({
          title: res.data.errorMsg,
          icon: 'none',
          duration: 1500
        });
      }
    });
  },
  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {
    this.data.pageIndex = 1;
    this.getMoreData();

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {
    this.data.pageIndex += 1;
    this.getMoreData();
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function() {

  }
})